package com.lemon.service.impl;

import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lemon.domain.LogisticsCompany;
import com.lemon.domain.PageResult;
import com.lemon.domain.vo.LogisticsCompanyVo;
import com.lemon.mapper.LogisticsCompanyMapper;
import com.lemon.service.LogisticsCompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogisticsCompanyServiceImpl extends     ServiceImpl<LogisticsCompanyMapper, LogisticsCompany> implements LogisticsCompanyService {

    @Autowired
    private LogisticsCompanyMapper logisticsCompanyMapper;


    @Override
    public PageResult getPage(Integer page, Integer pageSize, String companyName) {
        PageHelper.startPage(page,pageSize);
        List<LogisticsCompany> logisticsCompanies = logisticsCompanyMapper.selectList(Wrappers.<LogisticsCompany>lambdaQuery().like(ObjectUtils.isNotEmpty(companyName), LogisticsCompany::getCompanyName, companyName));
        Page page1 = (Page) logisticsCompanies;
        return new PageResult(page1.getTotal(),page1.getResult());
    }

    @Override
    public List<LogisticsCompanyVo> getList() {
        return logisticsCompanyMapper.getList();
    }
}
